package com.qianfeng.libra.cowshop.app.models;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fei on 2015/3/24.
 */
public class SpecialSubject {
    private String notice;
    private boolean result;
    private List<SubItem> list;


    public SpecialSubject(){
        list = new ArrayList<SubItem>();
    }
    public void parseJson(JSONObject jsonObject){
        try {
            notice = jsonObject.getString("notice");
            result = jsonObject.getBoolean("result");
            JSONObject info = jsonObject.getJSONObject("info");
            JSONArray topicsList = info.getJSONArray("TopicsList");
            for (int i = 0; i < topicsList.length(); i++) {
                SubItem subItem = new SubItem();
                JSONObject topicItem = topicsList.getJSONObject(i);
                subItem.setTopicId(topicItem.getInt("TopicID"));
                subItem.setTopicName(topicItem.getString("TopicName"));
                subItem.setType(topicItem.getInt("Type"));
                list.add(subItem);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String getNotice() {
        return notice;
    }

    public void setNotice(String notice) {
        this.notice = notice;
    }

    public boolean isResult() {
        return result;
    }

    public void setResult(boolean result) {
        this.result = result;
    }

    public List<SubItem> getList() {
        return list;
    }

}
